grammar toy;

module: stmt + ;

stmt : var_assign | print_op;

var_assign: Identifier EQUAL expression;

expression: (prim_expr (ADD prim_expr) ?) |
            (CONSTANT Number);

print_op: PRINT LB prim_expr RB;

prim_expr: Identifier | Number;

// lex

LB: '(';

RB: ')';

EQUAL: '=';

ADD: '+';

PRINT: 'print';

CONSTANT: 'constant';

Number: [0-9]+;

Identifier: [a-zA-Z][a-zA-Z0-9_]*;

WS: [ \r\n\t] -> skip;
    
Comment: '#' .*? '\n' ->skip;